package gridy.worker;

import gridy.master.Master;

import org.osoa.sca.annotations.EagerInit;
import org.osoa.sca.annotations.Init;
import org.osoa.sca.annotations.Reference;
import org.osoa.sca.annotations.Scope;

@EagerInit
@Scope("COMPOSITE")
public class WorkerImpl implements Worker {
    
    @Reference
    protected Master master;
    
    @Init
    public void init() {
        connectWithMaster();
    }
    
    private void connectWithMaster() {
        System.out.println();
        System.out.println("connectWithMaster");
        System.out.println();
        master.register("siebie");
    }


    @Override
    public void calculate(double[] arguments) {
        
        System.out.println();
        System.out.println("Calculate wywołany");
        for (double argument : arguments) {
            System.out.println("argument "+argument);
        }
        System.out.println();
    }

    @Override
    public void hello(String hello) {

        System.out.println();
        System.out.println("Hello: "+hello);
        System.out.println();
    }

}
